﻿<!--该分页控件需要依赖js引用【template-native.js】-->
<!--分页控件开始-->
<div class="dataTables_paginate paging_bootstrap_full_number" id="paginateDiv">
    <ul id="paging1" class="pagination" style="visibility: visible;"></ul>
</div>
<!--分页控件结束-->

<!--ajax分页控件,可以自定义页码样式-->
<script id="paging" type="text/html">
    <!--打印首页-->
    <% if(pageIndex==1){ %>
    <li class="prev disabled"><a href="javascript:void(0)" title="First">首页</a></li>
    <li class="prev disabled"><a href="javascript:void(0)" title="Prev">上一页</a></li>
    <% }else{ %>
    <li class="prev" pageIndex="1" onclick="goPage(this)"><a href="javascript:void(0)" title="First">首页</a></li>
    <li class="prev" pageIndex="<%=pageIndex-1%>" onclick="goPage(this)"><a href="javascript:void(0)" title="Prev">上一页</a></li>
    <%}%>
    <!--打印中间页码-->
    <% if(pageCount>=8) {%>
    <% for(var i = pageIndex-1; i>=pageIndex-3 && i>=1 ; i--){ %>
    <li pageIndex="<%=i%>" onclick="goPage(this)"><a href="javascript:void(0)"><%=i%></a></li>
    <%}%>
    <li class="active"><a href="#"><%=pageIndex%></a></li>
    <% for(var i = pageIndex+1; i<=pageIndex+3 && i<=pageCount; i++){ %>
    <li pageIndex="<%=i%>" onclick="goPage(this)"><a href="javascript:void(0)"><%=i%></a></li>
    <%}%>
    <%}else{%>
    <% for(var i = 1; i <=pageCount; i ++){ %>
    <%if(i==pageIndex){%>
    <li class="active"><a href="javascript:void(0)"><%=i%></a></li>
    <%}else{%>
    <li pageIndex="<%=i%>" onclick="goPage(this)"><a href="javascript:void(0)"><%=i%></a></li>
    <%}%>
    <%}%>
    <%}%>
    <!--打印尾页-->
    <%if(pageIndex==pageCount){%>
    <li class="next disabled"><a href="javascript:void(0)" title="Next">下一页</a></li>
    <li class="next disabled"><a href="javascript:void(0)" title="Last">尾页</a></li>
    <%}else{%>
    <li class="next" pageIndex="<%=pageIndex+1 %>" onclick="goPage(this)"><a href="javascript:void(0)" title="Next">下一页</a></li>
    <li class="next" pageIndex="<%=pageCount %>" onclick="goPage(this)"><a href="javascript:void(0)" title="Last">尾页</a></li>
    <%}%>
</script>
<script type="text/javascript">
    //页码
    var pageIndex = 1;
    //页大小
    var pageSize = 10;

    //点击分页控件页码
    function goPage(thisObj) {
        var index = $(thisObj).attr("pageIndex");
        pageIndex = index;
        GridData();//外部页面定义数据加载函数
    }

    //加载分页控件，pageIndex当前页码，pageCount查询出的总页数
    function loadPager(pageIndex, pageCount) {
        var pagination = { pageIndex: pageIndex, pageCount: pageCount };
        var pagingHTML = template('paging', pagination);
        document.getElementById('paging1').innerHTML = pagingHTML;
    }
</script>

